#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101

#include <Macros.h>
#include <CoVector.h>
#include <CoMatrix.h>
#include <CoCube.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Instrument.h>
#pragma unmanaged 
#include <ql\instruments\inflationcapfloor.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;

using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL::Cashflows;
using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#define STRUCT
namespace Cephei { namespace QL { namespace Instruments {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IYoYInflationCapFloor
	public ref class CYoYInflationCapFloor : 
            public CInstrument,
            public Cephei::QL::Instruments::IYoYInflationCapFloor
	{
	protected: 
		boost::shared_ptr<QuantLib::YoYInflationCapFloor>* _ppYoYInflationCapFloor;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::YoYInflationCapFloor>* _phYoYInflationCapFloor;
#endif
		Object^ _YoYInflationCapFloorOwner;     // reference to object that manages the storage for this object
	internal:
		CYoYInflationCapFloor (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ strikes, Cephei::QL::IPricingEngine^ QL_Pricer);
		CYoYInflationCapFloor (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ capRates, Cephei::IVector<Double>^ floorRates, Cephei::QL::IPricingEngine^ QL_Pricer);
        CYoYInflationCapFloor (boost::shared_ptr<QuantLib::YoYInflationCapFloor>& childNative, Object^ owner);
        CYoYInflationCapFloor (QuantLib::YoYInflationCapFloor& childNative, Object^ owner);
        CYoYInflationCapFloor (CYoYInflationCapFloor^ copy);
        CYoYInflationCapFloor (System::Type^ t);
#ifdef STRUCT
        CYoYInflationCapFloor (QuantLib::YoYInflationCapFloor childNative);
#endif       
#ifdef HANDLE
		CYoYInflationCapFloor (QuantLib::Handle<QuantLib::YoYInflationCapFloor>& childNative, Object^ owner);
		CYoYInflationCapFloor (QuantLib::Handle<QuantLib::YoYInflationCapFloor> childNative);
#endif
		virtual ~CYoYInflationCapFloor ();
		!CYoYInflationCapFloor ();

	internal:
		QuantLib::YoYInflationCapFloor& GetReference ();
		boost::shared_ptr<QuantLib::YoYInflationCapFloor>& GetShared ();
		QuantLib::YoYInflationCapFloor* GetPointer ();
        void SetYoYInflationCapFloor (boost::shared_ptr<QuantLib::YoYInflationCapFloor> native)
        {
            if (_ppYoYInflationCapFloor != NULL)
                delete _ppYoYInflationCapFloor;
            _ppYoYInflationCapFloor = new boost::shared_ptr<QuantLib::YoYInflationCapFloor> (native);
            SetInstrument (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::YoYInflationCapFloor>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Double AtmRate (Cephei::QL::Termstructures::IYieldTermStructure^ discountCurve) ;
        property Cephei::IVector<Double>^ CapRates 
        {
		    virtual Cephei::IVector<Double>^ get () ;
        }
        property Cephei::IVector<Double>^ FloorRates 
        {
		    virtual Cephei::IVector<Double>^ get () ;
        }
		virtual Double ImpliedVolatility (Double price, Cephei::QL::Termstructures::IYoYInflationTermStructure^ yoyCurve, Double guess, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy, Microsoft::FSharp::Core::FSharpOption<UInt32>^ maxEvaluations, Microsoft::FSharp::Core::FSharpOption<Double>^ minVol, Microsoft::FSharp::Core::FSharpOption<Double>^ maxVol) ;
        property Boolean IsExpired 
        {
		    virtual Boolean get () ;
        }
        property Cephei::QL::Cashflows::IYoYInflationCoupon^ LastYoYInflationCoupon 
        {
		    virtual Cephei::QL::Cashflows::IYoYInflationCoupon^ get () ;
        }
        property DateTime MaturityDate 
        {
		    virtual DateTime get () ;
        }
		virtual Cephei::QL::Instruments::IYoYInflationCapFloor^ Optionlet (UInt64 n) ;
        property DateTime StartDate 
        {
		    virtual DateTime get () ;
        }
        property QL::Instruments::YoYInflationCapFloor::TypeEnum Type 
        {
		    virtual QL::Instruments::YoYInflationCapFloor::TypeEnum get () ;
        }
        property Cephei::IVector<Cephei::QL::ICashFlow^>^ YoyLeg 
        {
		    virtual Cephei::IVector<Cephei::QL::ICashFlow^>^ get () ;
        }
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
	public ref class CYoYInflationCapFloor_Factory : public System::MarshalByRefObject,  public IYoYInflationCapFloor_Factory
	{
	public:
        virtual IYoYInflationCapFloor^ Create (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ strikes, Cephei::QL::IPricingEngine^ QL_Pricer);
        virtual IYoYInflationCapFloor^ Create (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ capRates, Cephei::IVector<Double>^ floorRates, Cephei::QL::IPricingEngine^ QL_Pricer);
    };
   
/*Cephei*/ } /*QL*/ } /*Instruments */}
